<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-L-admin1.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../css/xadmin.css">
    <script src="../js/jquery.min.js"></script>
    <script type="text/javascript" src="../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../js/xadmin.js"></script>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!--这里进行特别说明，不同于管理员查看试题的内容可以自己选择查看哪个老师的试题，本页面的查看要根据教师的身份自动做出筛选。-->
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">查看试题</a>
        <a>
          <cite>查看试题</cite></a>
      </span>
    <a class="layui-btn layui-btn-primary layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:38px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input type="text" name="proNo"  placeholder="请输入试题编号" id="proNo" autocomplete="off" class="layui-input" style="width: 160px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByNo" value="搜索"
                   onclick="searchProByNo()"/>
            <input type="text" name="proName"  placeholder="请输入试题关键字" id="proKey" autocomplete="off" class="layui-input">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByKey" value="搜索"
                   onclick="searchProByKey()"/>
            <input type="text" name="proType"  placeholder="请输入试题所属章节号" id="proChaNo" autocomplete="off" class="layui-input" style="width: 160px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByChaNo" value="搜索"
                   onclick="searchProByChaNo()"/>
           <input type="text" name="proType"  placeholder="请输入试题类型" id="proType" autocomplete="off" class="layui-input"style="width: 140px;">
            <input type="button" class="layui-btn" lay-submit="" lay-filter="search" id="searchByType" value="搜索"
                   onclick="searchProByType()"/>
            <br><br>
            <input type="button" class="layui-btn" id="showAll" onclick="showAllPro()" value="查看所有"/>
        </form>
    </div>
    <xblock>
        <button class="layui-btn" onclick="x_admin_show('添加试题','./problemAdd.html',1000,600)"><i class="layui-icon"></i>添加题目</button>
        <button class="layui-btn" onclick="x_admin_show('添加答案','./answerAdd.html',1000,600)"><i class="layui-icon"></i>添加答案</button>
        <span class="x-right" style="line-height:40px">本次搜索总共搜索到<b><font size="4px" color="red" id="number">这里填入搜索结果的统计数量</font></b>条数据</span>
    </xblock>
    <table class="layui-table">
        <thead >
        <tr>
            <th width="5%">试题编号</th>
            <th>试题详情</th>
            <th>试题对应答案</th>
            <th width="8%">试题关键字</th>
            <th width="7%">试题难度</th>
            <th width="3%">章节号</th>
            <th width="7%">章节名称</th>
            <th width="11%">章节要点</th>
            <th width="6%">试题类型</th>
            <th width="7%">教师编号</th>
            <th width="13%">修改</th>
        </tr>
        </thead>
        <tr id="pro"></tr>
        <td class="td-status" id="change"></td>
        <td id="proAnsno"></td>
        <tr id="pro0">
            <td id="proNo0"></td>
            <td id="proDetail0"></td>
            <td id="proAnsno0">
                <a title="答案"  id="answerShow0"  onclick="x_admin_show_sendId(this.title,'answerShow.html',800,600)" href="javascript:;" >
                <button class="layui-btn" >查看答案</button>
            </a>
            </td>
            <td id="proKey0"></td>
            <td id="proDif0"></td>
            <td id="chaNo0"></td>
            <td id="chaTitle0"></td>
            <td id="chaMpoint0"></td>
            <td id="proType0"></td>
            <td id="teaNo0"></td>
            <td class="td-status"  id="修改">
                <a title="修改" id="change0" onclick="x_admin_show_sendId(this.title,'problemChange.html')" href="javascript:;">
                    <button class="layui-btn layui-btn-warm ">修改</button>
                </a>
                <a title="删除"  id="delete0" onclick="member_del(this,this.title)" href="javascript:;">
                    <button class="layui-btn layui-btn-danger">删除</button>
                </a>
            </td>
        </tr>
        <tbody id="proList0">

        </tbody>
        <tbody id="proList">

        </tbody>
    </table>
</div>
<a title="答案"  id="answerShow" style="display: none" onclick="x_admin_show_sendId(this.title,'answerShow.html')" href="javascript:;" >
    <button class="layui-btn" >查看答案</button>
</a>
<input id="Id" type="hidden" name="teaId" value="">

<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
</script>
<script type="text/javascript">
    $("#Id").val(sessionStorage.getItem("teaId"));

    function showAllPro(){
    $.ajax({
        url: "/library/getproblemlist",
        type : "post",
        async: false,
        dataType: "json",
        data :null,
        // contentType: "application/json",
        success: function (data) {
            console.log("请求成功");
            console.log(data);
            var i=0;
            for (;;i++){
                if (data[i]){
                    if (i!==0){
                        var pro=document.getElementById("pro").cloneNode(true);
                        pro.id="pro"+i;
                        var proNo=document.getElementById("proNo0").cloneNode(true);
                        var proDetail=document.getElementById("proDetail0").cloneNode(true);
                        var proAnsno=document.getElementById("proAnsno").cloneNode(true);
                        var btn=document.getElementById("answerShow").cloneNode(true);
                        btn.style.display="block";
                        btn.title=data[i].proAnsno;
                        proAnsno.appendChild(btn);
                        var proKey=document.getElementById("proKey0").cloneNode(true);
                        var proDif=document.getElementById("proDif0").cloneNode(true);
                        var chaNo=document.getElementById("chaNo0").cloneNode(true);
                        var chaTitle=document.getElementById("chaTitle0").cloneNode(true);
                        var chaMpoint=document.getElementById("chaMpoint0").cloneNode(true);
                        var proType=document.getElementById("proType0").cloneNode(true);
                        var teaNo=document.getElementById("teaNo0").cloneNode(true);

                        proNo.innerHTML=data[i].proNo;
                        proDetail.innerHTML=data[i].proDetail;
                        proKey.innerHTML=data[i].proKeyw;
                        proDif.innerHTML=data[i].proDif;
                        chaNo.innerHTML=data[i].chaNo;
                        chaTitle.innerHTML=data[i].chaTitle;
                        chaMpoint.innerHTML=data[i].chaMpoint;
                        proType.innerHTML=data[i].proType;
                        teaNo.innerHTML=data[i].teaNo;

                        pro.appendChild(proNo);
                        pro.appendChild(proDetail);
                        pro.appendChild(proAnsno);
                        pro.appendChild(proKey);
                        pro.appendChild(proDif);
                        pro.appendChild(chaNo);
                        pro.appendChild(chaTitle);
                        pro.appendChild(chaMpoint);
                        pro.appendChild(proType);
                        pro.appendChild(teaNo);
                        var button=document.getElementById("change").cloneNode(true);
                        var change=document.getElementById("change0").cloneNode(true);
                        var del=document.getElementById("delete0").cloneNode(true);
                        del.title=data[i].proNo;
                        change.title=data[i].proNo;
                        button.appendChild(change);
                        button.appendChild(del);
                        pro.appendChild(button);

                        document.getElementById("proList0").appendChild(pro);
                        var j=i+1;
                        document.getElementById("number").innerHTML=j;
                    }
                    else if (i===0){
                        document.getElementById("change0").title=data[0].proNo;
                        document.getElementById("delete0").title=data[0].proNo;
                        document.getElementById("proNo0").innerHTML=data[0].proNo;
                        document.getElementById("proDetail0").innerHTML=data[0].proDetail;
                        document.getElementById("answerShow0").tltle=data[0].proAnsno;
                        console.log(document.getElementById("answerShow0").tltle);

                        document.getElementById("proKey0").innerHTML=data[0].proKeyw;
                        document.getElementById("proDif0").innerHTML=data[0].proDif;
                        document.getElementById("chaNo0").innerHTML=data[0].chaNo;
                        document.getElementById("chaTitle0").innerHTML=data[0].chaTitle;
                        document.getElementById("chaMpoint0").innerHTML=data[0].chaMpoint;
                        document.getElementById("proType0").innerHTML=data[0].proType;
                        document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                    }
                }
                else break;
            }
            document.getElementById("proList").innerHTML=null;
            for (i=1;;i++){
                if (data[i]){
                    document.getElementById("proList").appendChild(document.getElementById("pro"+i));
                }
                else break;
            }

            document.getElementById("proList0").innerHTML=null;
        },
        error: function (data) {
            console.log("请求失败");
        }
    });
    }
    function searchProByNo(){
        var No=$("#proNo").val();
        $.ajax({
            url: "/library/getprobyno",
            type : "post",
            async: false,
            dataType: "json",
            data :{proNo:No},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                console.log(data);
                            document.getElementById("change0").title=data.proNo;
                            document.getElementById("delete0").title=data.proNo;
                            document.getElementById("proNo0").innerHTML=data.proNo;
                            document.getElementById("proDetail0").innerHTML=data.proDetail;
                            document.getElementById("answerShow0").tltle=data.proAnsno;
                            console.log(document.getElementById("answerShow0").tltle);

                            document.getElementById("proKey0").innerHTML=data.proKeyw;
                            document.getElementById("proDif0").innerHTML=data.proDif;
                            document.getElementById("chaNo0").innerHTML=data.chaNo;
                            document.getElementById("chaTitle0").innerHTML=data.chaTitle;
                            document.getElementById("chaMpoint0").innerHTML=data.chaMpoint;
                            document.getElementById("proType0").innerHTML=data.proType;
                            document.getElementById("teaNo0").innerHTML=data.teaNo;

                document.getElementById("proList").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchProByKey(){
        var key=$("#proKey").val();
        $.ajax({
            url: "/library/getproblemlistbyprokeyw",
            type : "post",
            async: false,
            dataType: "json",
            data :{proKeyw:key},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                console.log(data);
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var pro=document.getElementById("pro").cloneNode(true);
                            pro.id="pro"+i;
                            var proNo=document.getElementById("proNo0").cloneNode(true);
                            var proDetail=document.getElementById("proDetail0").cloneNode(true);
                            var proAnsno=document.getElementById("proAnsno").cloneNode(true);
                            var btn=document.getElementById("answerShow").cloneNode(true);
                            btn.style.display="block";
                            btn.title=data[i].proAnsno;
                            proAnsno.appendChild(btn);
                            var proKey=document.getElementById("proKey0").cloneNode(true);
                            var proDif=document.getElementById("proDif0").cloneNode(true);
                            var chaNo=document.getElementById("chaNo0").cloneNode(true);
                            var chaTitle=document.getElementById("chaTitle0").cloneNode(true);
                            var chaMpoint=document.getElementById("chaMpoint0").cloneNode(true);
                            var proType=document.getElementById("proType0").cloneNode(true);
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);

                            proNo.innerHTML=data[i].proNo;
                            proDetail.innerHTML=data[i].proDetail;
                            proKey.innerHTML=data[i].proKeyw;
                            proDif.innerHTML=data[i].proDif;
                            chaNo.innerHTML=data[i].chaNo;
                            chaTitle.innerHTML=data[i].chaTitle;
                            chaMpoint.innerHTML=data[i].chaMpoint;
                            proType.innerHTML=data[i].proType;
                            teaNo.innerHTML=data[i].teaNo;

                            pro.appendChild(proNo);
                            pro.appendChild(proDetail);
                            pro.appendChild(proAnsno);
                            pro.appendChild(proKey);
                            pro.appendChild(proDif);
                            pro.appendChild(chaNo);
                            pro.appendChild(chaTitle);
                            pro.appendChild(chaMpoint);
                            pro.appendChild(proType);
                            pro.appendChild(teaNo);
                            var button=document.getElementById("change").cloneNode(true);
                            var change=document.getElementById("change0").cloneNode(true);
                            var del=document.getElementById("delete0").cloneNode(true);
                            del.title=data[i].proNo;
                            change.title=data[i].proNo;
                            button.appendChild(change);
                            button.appendChild(del);
                            pro.appendChild(button);

                            document.getElementById("proList0").appendChild(pro);
                            var j=i+1;
                            document.getElementById("number").innerHTML=j;
                        }
                        else if (i===0){
                            document.getElementById("change0").title=data[0].proNo;
                            document.getElementById("delete0").title=data[0].proNo;
                            document.getElementById("proNo0").innerHTML=data[0].proNo;
                            document.getElementById("proDetail0").innerHTML=data[0].proDetail;
                            document.getElementById("answerShow0").tltle=data[i].proAnsno;

                            document.getElementById("proKey0").innerHTML=data[0].proKeyw;
                            document.getElementById("proDif0").innerHTML=data[0].proDif;
                            document.getElementById("chaNo0").innerHTML=data[0].chaNo;
                            document.getElementById("chaTitle0").innerHTML=data[0].chaTitle;
                            document.getElementById("chaMpoint0").innerHTML=data[0].chaMpoint;
                            document.getElementById("proType0").innerHTML=data[0].proType;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                        }
                    }
                    else break;
                }
                document.getElementById("proList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("proList").appendChild(document.getElementById("pro"+i));
                    }
                    else break;
                }

                document.getElementById("proList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchProByChaNo(){
        var No=$("#proChaNo").val();
        $.ajax({
            url: "/library/getproblemlistbychano",
            type : "post",
            async: false,
            dataType: "json",
            data :{chaNo:No},
            // contentType: "application/json",
            success: function (data) {
                console.log("请求成功");
                console.log(data);
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var pro=document.getElementById("pro").cloneNode(true);
                            pro.id="pro"+i;
                            var proNo=document.getElementById("proNo0").cloneNode(true);
                            var proDetail=document.getElementById("proDetail0").cloneNode(true);
                            var proAnsno=document.getElementById("proAnsno").cloneNode(true);
                            var btn=document.getElementById("answerShow").cloneNode(true);
                            btn.style.display="block";
                            btn.title=data[i].proAnsno;
                            proAnsno.appendChild(btn);
                            var proKey=document.getElementById("proKey0").cloneNode(true);
                            var proDif=document.getElementById("proDif0").cloneNode(true);
                            var chaNo=document.getElementById("chaNo0").cloneNode(true);
                            var chaTitle=document.getElementById("chaTitle0").cloneNode(true);
                            var chaMpoint=document.getElementById("chaMpoint0").cloneNode(true);
                            var proType=document.getElementById("proType0").cloneNode(true);
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);

                            proNo.innerHTML=data[i].proNo;
                            proDetail.innerHTML=data[i].proDetail;
                            proKey.innerHTML=data[i].proKeyw;
                            proDif.innerHTML=data[i].proDif;
                            chaNo.innerHTML=data[i].chaNo;
                            chaTitle.innerHTML=data[i].chaTitle;
                            chaMpoint.innerHTML=data[i].chaMpoint;
                            proType.innerHTML=data[i].proType;
                            teaNo.innerHTML=data[i].teaNo;

                            pro.appendChild(proNo);
                            pro.appendChild(proDetail);
                            pro.appendChild(proAnsno);
                            pro.appendChild(proKey);
                            pro.appendChild(proDif);
                            pro.appendChild(chaNo);
                            pro.appendChild(chaTitle);
                            pro.appendChild(chaMpoint);
                            pro.appendChild(proType);
                            pro.appendChild(teaNo);
                            var button=document.getElementById("change").cloneNode(true);
                            var change=document.getElementById("change0").cloneNode(true);
                            var del=document.getElementById("delete0").cloneNode(true);
                            del.title=data[i].proNo;
                            change.title=data[i].proNo;
                            button.appendChild(change);
                            button.appendChild(del);
                            pro.appendChild(button);

                            document.getElementById("proList0").appendChild(pro);
                            var j=i+1;
                            document.getElementById("number").innerHTML=j;
                        }
                        else if (i===0){
                            document.getElementById("change0").title=data[0].proNo;
                            document.getElementById("delete0").title=data[0].proNo;
                            document.getElementById("proNo0").innerHTML=data[0].proNo;
                            document.getElementById("proDetail0").innerHTML=data[0].proDetail;
                            document.getElementById("answerShow0").tltle=data[i].proAnsno;

                            document.getElementById("proKey0").innerHTML=data[0].proKeyw;
                            document.getElementById("proDif0").innerHTML=data[0].proDif;
                            document.getElementById("chaNo0").innerHTML=data[0].chaNo;
                            document.getElementById("chaTitle0").innerHTML=data[0].chaTitle;
                            document.getElementById("chaMpoint0").innerHTML=data[0].chaMpoint;
                            document.getElementById("proType0").innerHTML=data[0].proType;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                        }
                    }
                    else break;
                }
                document.getElementById("proList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("proList").appendChild(document.getElementById("pro"+i));
                    }
                    else break;
                }

                document.getElementById("proList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
    function searchProByType(){
        var type=$("#proType").val();
        console.log(type);
        $.ajax({
            url: "/library/getproblemlistbyprotype",
            type : "post",
            async: false,
            dataType: "json",
            data :{proType:type},
            success: function (data) {
                console.log("请求成功");
                console.log(data);
                var i=0;
                for (;;i++){
                    if (data[i]){
                        if (i!==0){
                            var pro=document.getElementById("pro").cloneNode(true);
                            pro.id="pro"+i;
                            var proNo=document.getElementById("proNo0").cloneNode(true);
                            var proDetail=document.getElementById("proDetail0").cloneNode(true);
                            var proAnsno=document.getElementById("proAnsno").cloneNode(true);
                            var btn=document.getElementById("answerShow").cloneNode(true);
                            btn.style.display="block";
                            btn.title=data[i].proAnsno;
                            proAnsno.appendChild(btn);
                            var proKey=document.getElementById("proKey0").cloneNode(true);
                            var proDif=document.getElementById("proDif0").cloneNode(true);
                            var chaNo=document.getElementById("chaNo0").cloneNode(true);
                            var chaTitle=document.getElementById("chaTitle0").cloneNode(true);
                            var chaMpoint=document.getElementById("chaMpoint0").cloneNode(true);
                            var proType=document.getElementById("proType0").cloneNode(true);
                            var teaNo=document.getElementById("teaNo0").cloneNode(true);

                            proNo.innerHTML=data[i].proNo;
                            proDetail.innerHTML=data[i].proDetail;
                            proKey.innerHTML=data[i].proKeyw;
                            proDif.innerHTML=data[i].proDif;
                            chaNo.innerHTML=data[i].chaNo;
                            chaTitle.innerHTML=data[i].chaTitle;
                            chaMpoint.innerHTML=data[i].chaMpoint;
                            proType.innerHTML=data[i].proType;
                            teaNo.innerHTML=data[i].teaNo;

                            pro.appendChild(proNo);
                            pro.appendChild(proDetail);
                            pro.appendChild(proAnsno);
                            pro.appendChild(proKey);
                            pro.appendChild(proDif);
                            pro.appendChild(chaNo);
                            pro.appendChild(chaTitle);
                            pro.appendChild(chaMpoint);
                            pro.appendChild(proType);
                            pro.appendChild(teaNo);
                            var button=document.getElementById("change").cloneNode(true);
                            var change=document.getElementById("change0").cloneNode(true);
                            var del=document.getElementById("delete0").cloneNode(true);
                            del.title=data[i].proNo;
                            change.title=data[i].proNo;
                            button.appendChild(change);
                            button.appendChild(del);
                            pro.appendChild(button);

                            document.getElementById("proList0").appendChild(pro);
                            var j=i+1;
                            document.getElementById("number").innerHTML=j;
                        }
                        else if (i===0){
                            document.getElementById("change0").title=data[0].proNo;
                            document.getElementById("delete0").title=data[0].proNo;
                            document.getElementById("proNo0").innerHTML=data[0].proNo;
                            document.getElementById("proDetail0").innerHTML=data[0].proDetail;
                            document.getElementById("answerShow0").tltle=data[i].proAnsno;

                            document.getElementById("proKey0").innerHTML=data[0].proKeyw;
                            document.getElementById("proDif0").innerHTML=data[0].proDif;
                            document.getElementById("chaNo0").innerHTML=data[0].chaNo;
                            document.getElementById("chaTitle0").innerHTML=data[0].chaTitle;
                            document.getElementById("chaMpoint0").innerHTML=data[0].chaMpoint;
                            document.getElementById("proType0").innerHTML=data[0].proType;
                            document.getElementById("teaNo0").innerHTML=data[0].teaNo;
                        }
                    }
                    else break;
                }
                document.getElementById("proList").innerHTML=null;
                for (i=1;;i++){
                    if (data[i]){
                        document.getElementById("proList").appendChild(document.getElementById("pro"+i));
                    }
                    else break;
                }

                document.getElementById("proList0").innerHTML=null;
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }
</script>


<script>
    /*用户-删除*/
    function member_del(obj,id){
        $.ajax({
            url: "/library/deleteproblem",
            type : "post",
            async: false,
            dataType: "json",
            data : {proNo:id},

            success: function (data) {
                console.log('请求成功');
                if (data===1){
                    $.ajax({
                        url: "/library/getansnobyprono",
                        type : "post",
                        async: false,
                        dataType: "json",
                        data : {proNo:id},
                        success: function (data) {
                            console.log("请求成功");
                            console.log(data);
                            $.ajax({
                                url: "/library/deleteanswer",
                                type : "post",
                                async: false,
                                dataType: "json",
                                data :{ansNo:data},
                                // contentType :"application/json",
                                success: function (data) {
                                    console.log("请求成功");
                                    console.log(data);
                                },
                                error: function (data) {
                                    console.log("请求失败");
                                }
                            });
                        },
                        error: function (data) {
                            console.log("请求失败");

                        }
                    });

                    $(obj).parents("tr").remove();
                    alert("删除成功");}
                else alert("删除失败");
            },
            error: function (data) {
                console.log("请求失败");
            }
        });
    }




</script>

</body>

</html>